x86/shskt: Disable CET-SS on parts susceptible to fractured updates
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 3 Mar 2023 06:56:16 +0000 (07:56 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 3 Mar 2023 06:56:16 +0000 (07:56 +0100)
commit8202b9cf84674c5b23a89c4b8722afbb9787f917
treec1a75e34ff19ffa0a3010b3737e7e69d64beed20
parentcdc23d47ad85e756540eaa8655ebc2a0445612ed
x86/shskt: Disable CET-SS on parts susceptible to fractured updates

Refer to Intel SDM Rev 70 (Dec 2022), Vol3 17.2.3 "Supervisor Shadow Stack
Token".

Architecturally, an event delivery which starts in CPL<3 and switches shadow
stack will first validate the Supervisor Shadow Stack Token (setting the busy
bit), then pushes CS/LIP/SSP.  One example of this is an NMI interrupting Xen.

Some CPUs suffer from an issue called fracturing, whereby a fault/vmexit/etc
between setting the busy bit and completing the event injection renders the
action non-restartable, because when it comes time to restart, the busy bit is
found to be already set.

This is far more easily encountered under virt, yet it is not the fault of the
hypervisor, nor the fault of the guest kernel.  The fault lies somewhere
between the architectural specification, and the uarch behaviour.

Intel have allocated CPUID.7[1].ecx[18] CET_SSS to enumerate that supervisor
shadow stacks are safe to use.  Because of how Xen lays out its shadow stacks,
fracturing is not expected to be a problem on native.

Detect this case on boot and default to not using shstk if virtualised.
Specifying `cet=shstk` on the command line will override this heuristic and
enable shadow stacks irrespective.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 01e7477d1b081cff4288ff9f51ec59ee94c03ee0
master date: 2023-02-09 18:26:17 +0000
docs/misc/xen-command-line.pandoc
tools/libs/light/libxl_cpuid.c
tools/misc/xen-cpuid.c
xen/arch/x86/cpu/common.c
xen/arch/x86/setup.c
xen/include/public/arch-x86/cpufeatureset.h